﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using NUnit.Framework;

using ReferenceSwap;

namespace ReferenceSwap.Tests
{
    [TestFixture]
    public class AssemblyReferenceFixture
    {
        [Test]
        public void TestAssemblyReferenceParse()
        {
            string expectedName = "nunit.framework";
            string expectedPath = @"..\..\ext-libs\nunit.framework.dll";
            string expectedVersion = "2.6.1.12217";
            string expectedCulture = "neutral";
            string expectedPublicKey = "96d09a1eb7f44a77";
            string expectedArchitecture = "MSIL";

            var project = new ProjectData(@"..\..\ReferenceSwap.Tests.csproj");
            Assert.Greater(project.AssemblyReferences.Count, 0);
            var target = project.AssemblyReferences[0];

            Assert.AreEqual(expectedName, target.Name);
            Assert.AreEqual(expectedPath, target.Path);
            Assert.AreEqual(expectedVersion, target.MetaData["Version"]);
            Assert.AreEqual(expectedCulture, target.MetaData["Culture"]);
            Assert.AreEqual(expectedPublicKey, target.MetaData["PublicKeyToken"].ToLower());
            Assert.AreEqual(expectedArchitecture, target.MetaData["processorArchitecture"]);
        }

        [Test]
        public void TestAssemblyReferenceGenerateXml()
        {
            var project = new ProjectData(@"..\..\ReferenceSwap.Tests.csproj");
            Assert.Greater(project.AssemblyReferences.Count, 0);
            var target = project.AssemblyReferences[0].GenerateXml();

            Assert.IsNotNull(target);
        }

        [Test]
        public void TestAssemblyCtorWithPath()
        {
            string expectedName = "ReferenceSwap";
            string expectedPath = "ReferenceSwap.dll";
            string expectedVersion = "0.2.1.0";
            string expectedCulture = "neutral";
            string expectedProcessorArchitecture = "MSIL";

            var target = new AssemblyReference("ReferenceSwap.dll");

            Assert.AreEqual(expectedName, target.Name);
            Assert.AreEqual(expectedPath, target.Path);
            Assert.AreEqual(expectedVersion, target.MetaData["Version"]);
            Assert.AreEqual(expectedCulture, target.MetaData["Culture"]);
            Assert.AreEqual(expectedProcessorArchitecture, target.MetaData["processorArchitecture"]);
        }

        [Test]
        public void TestParseAssemblyFullName()
        {


        }
    }
}
